package com.woniuxy.user.mapper;

import com.woniuxy.commons.entity.UserCollect;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Author:阳佳
 * @Date: 2020/7/20 10:26
 * @Description:
 * @PACKAGE_NAME:com.woniuxy.user.mapper
 */
@Repository
@Mapper
public interface UserCollectMapper {
    /*
        增加一条收藏记录
     */
    @Insert("insert into user_collect values(default,#{uid},#{cid})")
    public int addCollectRecord(UserCollect userCollect);

    /*
    取消收藏-->删除状态
     */
    @Delete("delete from user_collect where uid=#{uid} and cid=#{cid}")
    public int cancelCollect(@Param("uid")String uid, @Param("cid")String cid);

    /*
    查看该用户所有的收藏
     */
    @Select("select * from user_collect where uid=#{uid}")
    public List<UserCollect> myAllCollect(@Param("uid")String uid);

    /*
    根据uid cid 查看某个用户是否对某个课程进行过收藏操作
     */
    @Select("select * from user_collect where uid=#{uid} and cid=#{cid}")
    public UserCollect findCollectRecordByUidAndCid(@Param("uid")String uid, @Param("cid")String cid);
}
